﻿using Common;
using IBLL;
using Microsoft.AspNetCore.Mvc;
using Models.DTO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Unmanned_MSUI.Areas.APP.Controllers
{
    [Area("APP")]
    public class HomeController : Controller
    {
        private ICommodityInfoBLL _commodityInfoBLL;
        public HomeController(
            ICommodityInfoBLL commodityInfoBLL
            )
        {
            _commodityInfoBLL = commodityInfoBLL;
        }

        public IActionResult IndexView()
        {
            return View();
        }

        #region 获取商品列表的接口（GetGoodsInfoList）

        /// <summary>
        /// 获取商品列表的接口
        /// </summary>
        /// <param name="page"></param>
        /// <param name="limit"></param>
        /// <param name="goodsName"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetCommodityInfoList(int page, int limit, string commodityName)
        {
            //声明一个总数
            int count;
            //先通过BLL调用查询用户列表的方法
            List<GetCommodityInfoDTO> list = _commodityInfoBLL.GetCommodityInfoList(page, limit, commodityName, out count);
            //实例化返回结果
            ReturnResult result = new ReturnResult()
            {
                Code = 0,         //成功
                Msg = "获取成功",//消息
                Data = list,    //数据
                Count = count, //总数
            };
            //返回结果
            return Json(result);
        }

        #endregion


    }



}
